<?php

/**
 * DevisFournisseur form base class.
 *
 * @method DevisFournisseur getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDevisFournisseurForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'date'            => new sfWidgetFormDate(),
      'reference'       => new sfWidgetFormInputText(),
      'lieu_livraison'  => new sfWidgetFormInputText(),
      'observation'     => new sfWidgetFormInputText(),
      'total_ht'        => new sfWidgetFormInputText(),
      'total_remise'    => new sfWidgetFormInputText(),
      'total_tva'       => new sfWidgetFormInputText(),
      'total_ttc'       => new sfWidgetFormInputText(),
      'total_netht'     => new sfWidgetFormInputText(),
      'total_fodec'     => new sfWidgetFormInputText(),
      'date_livraison'  => new sfWidgetFormDate(),
      'date_validite'   => new sfWidgetFormDate(),
      'mode_paiement'   => new sfWidgetFormChoice(array('choices' => array('Espece' => 'Espece', 'Cheque' => 'Cheque', 'Effet' => 'Effet'))),
      'id_fournisseur'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'add_empty' => true)),
      'id_representant' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Representant'), 'add_empty' => true)),
      'num_up_echeance' => new sfWidgetFormInputText(),
      'valider'         => new sfWidgetFormInputCheckbox(),
      'id_departement'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Departement'), 'add_empty' => true)),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'date'            => new sfValidatorDate(),
      'reference'       => new sfValidatorString(array('max_length' => 20)),
      'lieu_livraison'  => new sfValidatorString(array('max_length' => 70, 'required' => false)),
      'observation'     => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'total_ht'        => new sfValidatorNumber(array('required' => false)),
      'total_remise'    => new sfValidatorNumber(array('required' => false)),
      'total_tva'       => new sfValidatorNumber(array('required' => false)),
      'total_ttc'       => new sfValidatorNumber(array('required' => false)),
      'total_netht'     => new sfValidatorNumber(array('required' => false)),
      'total_fodec'     => new sfValidatorNumber(array('required' => false)),
      'date_livraison'  => new sfValidatorDate(array('required' => false)),
      'date_validite'   => new sfValidatorDate(array('required' => false)),
      'mode_paiement'   => new sfValidatorChoice(array('choices' => array(0 => 'Espece', 1 => 'Cheque', 2 => 'Effet'), 'required' => false)),
      'id_fournisseur'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'required' => false)),
      'id_representant' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Representant'), 'required' => false)),
      'num_up_echeance' => new sfValidatorNumber(array('required' => false)),
      'valider'         => new sfValidatorBoolean(array('required' => false)),
      'id_departement'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Departement'), 'required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('devis_fournisseur[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DevisFournisseur';
  }

}
